/*
 Navicat Premium Data Transfer

 Source Server         : localhost
 Source Server Type    : MySQL
 Source Server Version : 50720
 Source Host           : localhost:3306
 Source Schema         : oauth2

 Target Server Type    : MySQL
 Target Server Version : 50720
 File Encoding         : 65001

 Date: 22/03/2022 18:53:02
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for client
-- ----------------------------
DROP TABLE IF EXISTS `client`;
CREATE TABLE `client` (
  `id` varchar(68) NOT NULL COMMENT '主键',
  `client_id` varchar(145) NOT NULL COMMENT '客户端标识',
  `client_secret` varchar(145) NOT NULL COMMENT '客户端秘钥',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `enabled` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否可用',
  `del` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否删除',
  `platform` varchar(28) NOT NULL DEFAULT '1' COMMENT '平台ID',
  `logo` varchar(145) NOT NULL DEFAULT '' COMMENT '客户端LOGO',
  `root_url` varchar(45) NOT NULL DEFAULT '' COMMENT '根URL',
  `descr` varchar(145) NOT NULL DEFAULT '' COMMENT '描述',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `index_client_secret` (`client_secret`),
  KEY `index_platform_id` (`platform`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='客户端信息';

-- ----------------------------
-- Records of client
-- ----------------------------
BEGIN;
INSERT INTO `client` VALUES ('1', '1001', '2', '2021-08-06 07:15:26', 0, 0, '7', '', '', '测试');
COMMIT;

-- ----------------------------
-- Table structure for client_allow_url
-- ----------------------------
DROP TABLE IF EXISTS `client_allow_url`;
CREATE TABLE `client_allow_url` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `client_id` varchar(145) NOT NULL COMMENT '客户端ID',
  `allow_url` varchar(245) NOT NULL COMMENT '允许的URL',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `del` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否删除',
  PRIMARY KEY (`id`),
  KEY `index_client_id` (`client_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COMMENT='应用允许授权的URL';

-- ----------------------------
-- Records of client_allow_url
-- ----------------------------
BEGIN;
INSERT INTO `client_allow_url` VALUES (1, '1001', '*', '2021-08-06 07:20:15', 0);
COMMIT;

-- ----------------------------
-- Table structure for client_roles
-- ----------------------------
DROP TABLE IF EXISTS `client_roles`;
CREATE TABLE `client_roles` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `role_id` bigint(20) NOT NULL COMMENT '角色ID',
  `client_id` bigint(20) NOT NULL COMMENT '客户端ID',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `index_role_id` (`role_id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COMMENT='客户端角色';

-- ----------------------------
-- Records of client_roles
-- ----------------------------
BEGIN;
INSERT INTO `client_roles` VALUES (1, 1, 1);
INSERT INTO `client_roles` VALUES (3, 2, 1);
COMMIT;

-- ----------------------------
-- Table structure for client_scope
-- ----------------------------
DROP TABLE IF EXISTS `client_scope`;
CREATE TABLE `client_scope` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `scope_id` bigint(20) NOT NULL COMMENT '作用域ID',
  `client_id` varchar(145) NOT NULL COMMENT '客户端ID',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `show` tinyint(4) NOT NULL DEFAULT '1' COMMENT '授权是否显示文字',
  `show_text` varchar(45) NOT NULL DEFAULT '' COMMENT '授权显示文字的内容',
  PRIMARY KEY (`id`),
  KEY `index_scope_id` (`scope_id`),
  KEY `index_client_id` (`client_id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COMMENT='客户端作用域';

-- ----------------------------
-- Records of client_scope
-- ----------------------------
BEGIN;
INSERT INTO `client_scope` VALUES (1, 1, '1001', '2021-08-06 07:20:30', 1, '');
INSERT INTO `client_scope` VALUES (2, 2, '1001', '2021-08-06 07:20:30', 1, '');
COMMIT;

-- ----------------------------
-- Table structure for permissions
-- ----------------------------
DROP TABLE IF EXISTS `permissions`;
CREATE TABLE `permissions` (
  `permissions_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '权限ID',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `name` varchar(45) NOT NULL COMMENT '权限名称',
  `descr` varchar(145) NOT NULL DEFAULT '' COMMENT '权限描述',
  `value` varchar(45) NOT NULL COMMENT '权限值',
  `del` tinyint(4) NOT NULL DEFAULT '1' COMMENT '是否删除',
  `enabled` tinyint(4) NOT NULL DEFAULT '1' COMMENT '是否可用',
  PRIMARY KEY (`permissions_id`),
  KEY `index_name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COMMENT='权限';

-- ----------------------------
-- Records of permissions
-- ----------------------------
BEGIN;
INSERT INTO `permissions` VALUES (1, '2021-08-04 15:10:11', '测试', 'get', 'get', 1, 1);
INSERT INTO `permissions` VALUES (2, '2021-08-24 11:15:01', 'user-add', '', 'user-add', 1, 1);
INSERT INTO `permissions` VALUES (3, '2021-08-24 11:15:10', 'user-delete', '', 'user-delete', 1, 1);
INSERT INTO `permissions` VALUES (4, '2021-08-24 11:15:18', 'user-update', 'user-update', 'user-update', 1, 1);
INSERT INTO `permissions` VALUES (5, '2021-08-24 11:15:34', 'user-get', 'user-get', 'user-get', 1, 1);
COMMIT;

-- ----------------------------
-- Table structure for platform
-- ----------------------------
DROP TABLE IF EXISTS `platform`;
CREATE TABLE `platform` (
  `platform` varchar(78) NOT NULL COMMENT '平台ID',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `enabled` tinyint(4) NOT NULL DEFAULT '1' COMMENT '是否可用',
  `name` varchar(45) NOT NULL COMMENT '平台名称',
  `descr` varchar(345) NOT NULL DEFAULT '' COMMENT '平台描述',
  `logo` varchar(145) NOT NULL DEFAULT '' COMMENT '平台LOGO',
  `code` varchar(255) NOT NULL COMMENT '平台标识',
  PRIMARY KEY (`platform`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='平台';

-- ----------------------------
-- Records of platform
-- ----------------------------
BEGIN;
INSERT INTO `platform` VALUES ('1', '2021-08-04 15:05:39', 1, 'qxcx', 'csap开发平台', '', 'csap');
COMMIT;

-- ----------------------------
-- Table structure for platform_roles
-- ----------------------------
DROP TABLE IF EXISTS `platform_roles`;
CREATE TABLE `platform_roles` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `role_id` bigint(20) NOT NULL COMMENT '角色ID',
  `platfrom_id` bigint(20) NOT NULL COMMENT '平台的ID',
  PRIMARY KEY (`id`),
  KEY `index_platfrom_id` (`platfrom_id`),
  KEY `index_role_id` (`role_id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COMMENT='平台角色';

-- ----------------------------
-- Records of platform_roles
-- ----------------------------
BEGIN;
INSERT INTO `platform_roles` VALUES (1, 1, 1);
INSERT INTO `platform_roles` VALUES (2, 2, 1);
COMMIT;

-- ----------------------------
-- Table structure for roles
-- ----------------------------
DROP TABLE IF EXISTS `roles`;
CREATE TABLE `roles` (
  `role_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '角色ID',
  `name` varchar(45) NOT NULL COMMENT '角色名称',
  `descr` varchar(145) NOT NULL DEFAULT '' COMMENT '描述',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `type` int(11) NOT NULL COMMENT '角色类型1平台2客户端',
  `defaults` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否默认角色',
  PRIMARY KEY (`role_id`),
  KEY `index_type` (`type`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COMMENT='角色';

-- ----------------------------
-- Records of roles
-- ----------------------------
BEGIN;
INSERT INTO `roles` VALUES (1, 'admin', '超级管理员', '2021-08-04 15:06:07', 1, 1);
INSERT INTO `roles` VALUES (2, 'super-admin', '超级管理员', '2021-08-04 15:06:07', 2, 1);
COMMIT;

-- ----------------------------
-- Table structure for roles_attribute
-- ----------------------------
DROP TABLE IF EXISTS `roles_attribute`;
CREATE TABLE `roles_attribute` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '角色ID',
  `name` varchar(45) NOT NULL COMMENT '属性名',
  `value` varchar(145) NOT NULL DEFAULT '' COMMENT '属性值',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `role_id` bigint(20) NOT NULL COMMENT '角色的ID',
  `descr` varchar(45) NOT NULL DEFAULT '' COMMENT '描述',
  PRIMARY KEY (`id`),
  KEY `index_role_id` (`role_id`),
  KEY `index_name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COMMENT='角色属性';

-- ----------------------------
-- Records of roles_attribute
-- ----------------------------
BEGIN;
INSERT INTO `roles_attribute` VALUES (1, 'name', '张三', '2021-08-04 15:06:40', 1, '');
COMMIT;

-- ----------------------------
-- Table structure for roles_permissions
-- ----------------------------
DROP TABLE IF EXISTS `roles_permissions`;
CREATE TABLE `roles_permissions` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `role_id` bigint(20) NOT NULL COMMENT '角色ID',
  `permissions_id` bigint(20) NOT NULL COMMENT '权限ID',
  PRIMARY KEY (`id`),
  KEY `index_role_id` (`role_id`),
  KEY `index_permissions_id` (`permissions_id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COMMENT='角色权限';

-- ----------------------------
-- Records of roles_permissions
-- ----------------------------
BEGIN;
INSERT INTO `roles_permissions` VALUES (1, 1, 1);
INSERT INTO `roles_permissions` VALUES (2, 1, 2);
INSERT INTO `roles_permissions` VALUES (3, 1, 3);
INSERT INTO `roles_permissions` VALUES (4, 1, 4);
INSERT INTO `roles_permissions` VALUES (5, 2, 5);
COMMIT;

-- ----------------------------
-- Table structure for scope
-- ----------------------------
DROP TABLE IF EXISTS `scope`;
CREATE TABLE `scope` (
  `scope_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '作用域ID',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `name` varchar(45) NOT NULL COMMENT '作用域名称',
  `descr` varchar(145) NOT NULL DEFAULT '' COMMENT '作用域描述',
  `del` tinyint(4) NOT NULL DEFAULT '1' COMMENT '授权是否显示文字',
  PRIMARY KEY (`scope_id`),
  KEY `index_name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COMMENT='作用域';

-- ----------------------------
-- Records of scope
-- ----------------------------
BEGIN;
INSERT INTO `scope` VALUES (1, '2021-08-06 07:15:59', 'userinfo', '测试作用域', 1);
INSERT INTO `scope` VALUES (2, '2022-01-23 17:43:58', 'ride_order', '骑行订单授权', 1);
COMMIT;

-- ----------------------------
-- Table structure for scope_permissions
-- ----------------------------
DROP TABLE IF EXISTS `scope_permissions`;
CREATE TABLE `scope_permissions` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `scope_id` bigint(20) NOT NULL COMMENT '作用域ID',
  `permissions_id` bigint(20) NOT NULL COMMENT '权限ID',
  PRIMARY KEY (`id`),
  KEY `index_scope_id` (`scope_id`),
  KEY `index_permissions_id` (`permissions_id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COMMENT='作用域权限';

-- ----------------------------
-- Records of scope_permissions
-- ----------------------------
BEGIN;
INSERT INTO `scope_permissions` VALUES (1, 1, 1);
INSERT INTO `scope_permissions` VALUES (2, 1, 2);
COMMIT;

-- ----------------------------
-- Table structure for user_attribute
-- ----------------------------
DROP TABLE IF EXISTS `user_attribute`;
CREATE TABLE `user_attribute` (
  `attribute_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '属性ID',
  `user_id` varchar(45) NOT NULL COMMENT '用户ID',
  `name` varchar(45) NOT NULL COMMENT '属性名',
  `value` varchar(45) NOT NULL COMMENT '属性值',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `open_id` varchar(255) NOT NULL DEFAULT '' COMMENT '用户的openId',
  PRIMARY KEY (`attribute_id`) USING BTREE,
  KEY `index_user_id` (`user_id`),
  KEY `index_name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COMMENT='用户属性';

-- ----------------------------
-- Records of user_attribute
-- ----------------------------
BEGIN;
INSERT INTO `user_attribute` VALUES (1, '2e1dd56592e84e023aa7fabcf72ee73e', 'name', '[\"张三\"]', '2021-08-16 06:10:05', '');
COMMIT;

-- ----------------------------
-- Table structure for user_info
-- ----------------------------
DROP TABLE IF EXISTS `user_info`;
CREATE TABLE `user_info` (
  `user_id` varchar(145) NOT NULL COMMENT '用户ID',
  `user_name` varchar(45) NOT NULL COMMENT '用户名',
  `password` varchar(345) NOT NULL COMMENT '密码',
  `enabled` tinyint(4) NOT NULL DEFAULT '1' COMMENT '是否可用',
  `email` varchar(45) NOT NULL DEFAULT '' COMMENT '邮箱',
  `nick_name` varchar(45) NOT NULL COMMENT '昵称',
  `avatar` varchar(145) NOT NULL DEFAULT '' COMMENT '头像',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '注册时间',
  `last_login_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最后登录时间',
  `login_count` bigint(20) NOT NULL DEFAULT '1' COMMENT '登录次数',
  `platform` varchar(28) NOT NULL DEFAULT '' COMMENT '平台ID',
  `mobile` varchar(28) NOT NULL COMMENT '手机号码',
  `sex` int(11) NOT NULL DEFAULT '0' COMMENT '性别',
  `age` int(11) NOT NULL DEFAULT '18' COMMENT '年龄',
  `region_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '区域ID',
  `address` varchar(45) NOT NULL DEFAULT '' COMMENT '用户注册地址',
  `ip` varchar(15) NOT NULL DEFAULT '' COMMENT '注册的IP',
  `user_type` varchar(28) NOT NULL DEFAULT 'default' COMMENT '用户类型',
  PRIMARY KEY (`user_id`),
  UNIQUE KEY `index_user_name` (`user_name`) USING BTREE,
  UNIQUE KEY `index_mobile` (`mobile`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户信息表';

-- ----------------------------
-- Records of user_info
-- ----------------------------
BEGIN;
INSERT INTO `user_info` VALUES ('2e1dd56592e84e023aa7fabcf72ee73e', '13018927256', '8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92', 1, '', '13018927256', '', '2021-08-16 06:10:05', '2021-08-16 06:10:05', 1, '1', '13018927256', 0, 18, 0, '', 'localhost', 'default');
COMMIT;

-- ----------------------------
-- Table structure for user_open_info
-- ----------------------------
DROP TABLE IF EXISTS `user_open_info`;
CREATE TABLE `user_open_info` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `client_id` varchar(145) NOT NULL COMMENT '客户端的ID',
  `user_id` varchar(45) NOT NULL COMMENT '用户ID',
  `open_id` varchar(145) NOT NULL COMMENT '用户的opendId',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `index_client_id` (`client_id`),
  KEY `index_user_id` (`user_id`),
  KEY `index_open_id` (`open_id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COMMENT='用户开放的相关信息';

-- ----------------------------
-- Records of user_open_info
-- ----------------------------
BEGIN;
INSERT INTO `user_open_info` VALUES (3, '1001', '2e1dd56592e84e023aa7fabcf72ee73e', 'WX_IDftpwH5uXwOje_FjlpJPaeZss37vvo__', '2021-08-16 06:10:05');
COMMIT;

-- ----------------------------
-- Table structure for user_roles
-- ----------------------------
DROP TABLE IF EXISTS `user_roles`;
CREATE TABLE `user_roles` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `role_id` bigint(20) NOT NULL COMMENT '角色ID',
  `user_id` varchar(145) NOT NULL COMMENT '客户端ID',
  `open_id` varchar(255) NOT NULL DEFAULT '' COMMENT '用户的openId',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `index_role_id` (`role_id`),
  KEY `index_user_id` (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COMMENT='用户的角色';

-- ----------------------------
-- Records of user_roles
-- ----------------------------
BEGIN;
INSERT INTO `user_roles` VALUES (3, 1, '2e1dd56592e84e023aa7fabcf72ee73e', 'WX_IDftpwH5uXwOje_FjlpJPaeZss37vvo__');
INSERT INTO `user_roles` VALUES (4, 2, '2e1dd56592e84e023aa7fabcf72ee73e', 'WX_IDftpwH5uXwOje_FjlpJPaeZss37vvo__');
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;
